<script type="text/javascript"><!--//--><![CDATA[//><!--

	var grid_reload = function(){
		$('#datagrid').datagrid('reload', $('#fm_search').serializeObject());
	};

    var grid_reload_filter = function(){
        var bulan_dari = $('#bulan_dari').val();
        var bulan_sampai = $('#bulan_sampai').val();
        var tahun = $('#tahun').val();
        $('#datagrid').datagrid('reload', {'set':'filter','bulan_dari':bulan_dari,'bulan_sampai':bulan_sampai,'tahun':tahun});           
    };


	$(document).ready(function() {

		var no_konfirmasi = '<?php echo $no_konfirmasi; ?>'


		// Setup Datagrid
		$('#datagrid').datagrid({  
			url:gs_path+'/'+controller+'/getdata', 
			queryParams: $('#fm_search').serializeObject(),
			height:450,
			pagination:true,
			//singleSelect:true,	
			columns:[[
				{ field : 'ck', checkbox:true, width: 40, align: 'center' },
				{ field : 'no_toko', title : 'No Toko', width:150, sortable:true, rowspan:2},
				{ field : 'nama_tenant', title : 'Nama Tenant', width:200, sortable:true, rowspan:2},
				{ field : 'jenis_usaha', title : 'Jenis Usaha', width:200, sortable:true, rowspan:2},
				{ field : 'lokasi_tempat', title : 'Lokasi Tempat', width: 250, sortable:true, rowspan:2},
                { field : 'periode_pembayaran', title : 'Periode Pembayaran', width: 250, sortable:true, rowspan:2},
				{ field : 'status_bayar', title : 'Status Bayar', width:100, sortable:true, rowspan:2},
				
			]]
		});
        

        // Setup Form
		$('#form_master').setupForm([
			{ name: 'bulan_dari', type: 'text', size: 'short'},
            { name: 'bulan_sampai', type: 'text', size: 'short'},
            { name: 'tahun', type: 'text', size: 'short'},
            { name: 'status_bayar', type: 'text', size: 'medium'},
            { name: 'status_bayar_b', type: 'text', size: 'medium'},
			{ name: 'no_konfirmasi', type: 'text', size: 'medium'},
		]);

		$('#no_konfirmasi').setval(no_konfirmasi);

        // Set Action Button
        var buttons = [ 
                        // ----- >> Print Button
					     { label: 'Print PDF', icon: 'print', onclick: function() {
                                var oSel = $('#datagrid').datagrid('getSelected');
                            if (oSel == null) {
                                $.messager.alert('&nbsp;', gs_msg_row_unselected, 'warning'); 
                            } else {
                                var no_konfirmasi   = $('#no_konfirmasi').val();
                                var lokasi_tempat   = oSel['lokasi_tempat'];
                                var no_toko   = oSel['no_toko'];

                                var trigger = no_konfirmasi+','+lokasi_tempat+','+no_toko;
                              window.open(gs_path+'/'+controller+'/cetak/?trigger='+trigger, 'myWin', 'height=500,width=700,status=yes,toolbar=no,menubar=yes,location=no,scrollbars=yes');
        // window.location = gs_path + '/pro_lap_konfirmasi_tagihan/cetak/?data_tenant='+data_tenant+'&& no_konfirmasi='+no_konfirmasi;

                            } 

                        }}, { label: 'Print Satuan', icon: 'print', onclick: function() {
					     		/*var bulan = $('#bulan').val();
								var tahun = $('#tahun').val();
								var tanggal = bulan+'-'+tahun;*/
								var no_konfirmasi = $('#no_konfirmasi').val();
						    	var oSel = $('#datagrid').datagrid('getSelected');
						        if (oSel == null) {
						            $.messager.alert('&nbsp;', gs_msg_row_unselected, 'warning'); 
						        } else {
						        	var no_toko = oSel['no_toko'];
						        	var lokasi_tempat = oSel['lokasi_tempat'];
						        	var data_tenant = no_toko + ',' + lokasi_tempat;
									window.location = gs_path + '/pro_print_excel_new/konfirmasi_tagihan/?data_tenant='+data_tenant+'&& no_konfirmasi='+no_konfirmasi;
						        } 
					     }},
					    ];
        setAction(buttons);
		
		
		$('#fm_search').focusFirst();
    });
//--><!]]></script>

    
<div id="tb" style="padding:5px;height:auto">
    <div>
        <form id="fm_search" onsubmit="grid_reload(); return false;">
        	<table class="tb_form" style="margin-bottom:0px">
        	<tr>
        		<td class="label" style="width:70px">No Konfirmasi</td><td><input id="no_konfirmasi" name="no_konfirmasi"/> *silahkan input No konfirmasi</td>
        	</tr>
            <tr>
        			<td class="label" style="width:70px">Periode Tagihan</td>
                    <td colspan= "3"><select id="bulan_dari" name="bulan_dari">
                        <option value="01">Januari</option>
                        <option value="02">Februari</option>
                        <option value="03">Maret</option>
                        <option value="04">April</option>
                        <option value="05">Mei</option>
                        <option value="06">Juni</option>
                        <option value="07">Juli</option>
                        <option value="08">Agustus</option>
                        <option value="09">September</option>
                        <option value="10">Oktober</option>
                        <option value="11">November</option>
                        <option value="12">Desember</option>
                    </select> S/D 
                   <select id="bulan_sampai" name="bulan_sampai">
                        <option value="01">Januari</option>
                        <option value="02">Februari</option>
                        <option value="03">Maret</option>
                        <option value="04">April</option>
                        <option value="05">Mei</option>
                        <option value="06">Juni</option>
                        <option value="07">Juli</option>
                        <option value="08">Agustus</option>
                        <option value="09">September</option>
                        <option value="10">Oktober</option>
                        <option value="11">November</option>
                        <option value="12">Desember</option>
                    </select> Tahun 
                    <?php
                    $now = date('Y');
                    $pastYear = $now - 10; 
                    echo "<select id='tahun' name='tahun' >";
                    for ($a=$pastYear;$a<=$now;$a++)
                    {
                        echo"<option value='".$a."''>".$a."</option>";  
                    }
                    echo"</select>";
                    ?>
                    
                    <a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="grid_reload_filter(); return false;">Filter Bersarkan Peroide Tagihian</a>
             </tr>
             <tr>
            	<td width="100">Keyword (All Search)</td>
                 <td colspan="6"><input type="text" id="keyword" name="keyword" class="textfield medium" />
                	<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="grid_reload(); return false;">Search</a>
                </td>
            </tr>
            </table>
        </form>
    </div>
</div>
<div id="datagrid" toolbar="#tb"></div>
